package com.miyu.video.controller;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.miyu.common.pojo.PageServe;
import com.miyu.video.service.VideoService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.Resources;

/**
 * 视频
 * 1.搜索 2 导航 3 首页热播 4 视频详情 5 播放地址
 *
 * @author MIYU
 */
@RestController
public class Video {

    @Resource
    private VideoService videoService ;
    @RequestMapping("SearchVideo")
    public JSONArray SearchVideo(@RequestBody JSONObject params){
        JSONArray result = new JSONArray();
        return result;
    }

    /**
     * 查询导航
     * @return {@link String}
     */
    @RequestMapping("queryNav")
    public JSONArray queryVideoNva(@RequestBody JSONObject params) {
        JSONArray result = new JSONArray();
        // JSONObject obj = new JSONObject();
        // JSONObject obj1 = new JSONObject();
        // JSONObject obj2 = new JSONObject();
        // JSONObject obj3 = new JSONObject();
        // obj.put("name", "日本动漫");
        // obj.put("url", "http://localhost");
        // result.add(obj);
        // obj1.put("name", "国产动漫");
        // obj1.put("url", "http://localhost");
        // result.add(obj1);
        // obj2.put("name", "美国动漫");
        // obj2.put("url", "http://localhost");
        // result.add(obj2);
        // obj3.put("name", "欧美动漫");
        // obj3.put("url", "http://localhost");
        // result.add(obj3);

        result =  videoService.queryVideoNav(params);
        return result;
    }

    /**
     * 查询视频热点(首页热点数据)
     * @param ruleId obj
     * @return {@link JSONArray}
     */
    @RequestMapping("queryVideoHots")
    public JSONArray queryVideoHots(@RequestBody JSONObject ruleId){
        JSONArray result = new JSONArray();
        JSONObject obj = new JSONObject();
        obj.put("name", "日本动漫");
        JSONArray details = new JSONArray();
        JSONObject detail = new JSONObject();
        detail.put("name", "冰属性男子与酷酷女同事酷酷女同事");
        detail.put("img", "https://sakura.xonlines.com/upload/vod/20230117-1/f651442adc9db74d02d1242b0d1f4be6.jpg");
        detail.put("url", "http://www.dm88.me/view/10149.html");
        details.add(detail);
        obj.put("data",details );
        result.add(obj);
        JSONObject obj1 = new JSONObject();
        obj1.put("name", "国产动漫");
        JSONArray details1 = new JSONArray();
        JSONObject detail1 = new JSONObject();
        detail1.put("name", "冰属性男子与酷酷女同事酷酷女同事");
        detail1.put("img", "https://sakura.xonlines.com/upload/vod/20230117-1/f651442adc9db74d02d1242b0d1f4be6.jpg");
        detail1.put("url", "http://www.dm88.me/view/10149.html");
        details1.add(detail1);
        obj1.put("data",details1 );
        result.add(obj1);
        return result;
    }

    /**
     * 查询视频细节
     * @param params 参数个数
     * @return {@link JSONObject}
     */
    @RequestMapping("queryVideoDetails")
    public JSONObject queryVideoDetails(@RequestBody JSONObject params){
        JSONObject result = new JSONObject();
        return result;
    }
}
